package designpatterns.factory.abs.code;

import java.util.Objects;

/**
 * 小米工厂
 */
public class MiFactory implements PhoneAbstractFactory {
    @Override
    public Phone creatPhone(String version) throws RuntimeException{
        System.out.println("获取手机:"+version);
        Phone phone = null;
        switch (version) {
            case "MI_12" : phone = new Mi12();break;
            case "REDMI_K50" : phone = new RedMiK50();break;
        }
        if(Objects.isNull(phone)) {
            throw new RuntimeException("没有这样的手机！");
        }
        return phone;
    }
}
